package com.fr.base.core.image4j.codec.bmp;

import com.fr.base.core.image4j.io.LittleEndianInputStream;
import com.fr.base.core.image4j.io.LittleEndianOutputStream;
import java.io.IOException;

public class InfoHeader
{
  public int iSize;
  public int iWidth;
  public int iHeight;
  public short sPlanes;
  public short sBitCount;
  public int iCompression;
  public int iImageSize;
  public int iXpixelsPerM;
  public int iYpixelsPerM;
  public int iColorsUsed;
  public int iColorsImportant;
  public int iNumColors;

  public InfoHeader(LittleEndianInputStream paramLittleEndianInputStream)
    throws IOException
  {
    this.iSize = paramLittleEndianInputStream.readIntLE();
    init(paramLittleEndianInputStream, this.iSize);
  }

  public InfoHeader(LittleEndianInputStream paramLittleEndianInputStream, int paramInt)
    throws IOException
  {
    init(paramLittleEndianInputStream, paramInt);
  }

  protected void init(LittleEndianInputStream paramLittleEndianInputStream, int paramInt)
    throws IOException
  {
    this.iSize = paramInt;
    this.iWidth = paramLittleEndianInputStream.readIntLE();
    this.iHeight = paramLittleEndianInputStream.readIntLE();
    this.sPlanes = paramLittleEndianInputStream.readShortLE();
    this.sBitCount = paramLittleEndianInputStream.readShortLE();
    this.iNumColors = (int)Math.pow(2.0D, this.sBitCount);
    this.iCompression = paramLittleEndianInputStream.readIntLE();
    this.iImageSize = paramLittleEndianInputStream.readIntLE();
    this.iXpixelsPerM = paramLittleEndianInputStream.readIntLE();
    this.iYpixelsPerM = paramLittleEndianInputStream.readIntLE();
    this.iColorsUsed = paramLittleEndianInputStream.readIntLE();
    this.iColorsImportant = paramLittleEndianInputStream.readIntLE();
  }

  public InfoHeader()
  {
    this.iSize = 40;
    this.iWidth = 0;
    this.iHeight = 0;
    this.sPlanes = 1;
    this.sBitCount = 0;
    this.iNumColors = 0;
    this.iCompression = 0;
    this.iImageSize = 0;
    this.iXpixelsPerM = 0;
    this.iYpixelsPerM = 0;
    this.iColorsUsed = 0;
    this.iColorsImportant = 0;
  }

  public InfoHeader(InfoHeader paramInfoHeader)
  {
    this.iColorsImportant = paramInfoHeader.iColorsImportant;
    this.iColorsUsed = paramInfoHeader.iColorsUsed;
    this.iCompression = paramInfoHeader.iCompression;
    this.iHeight = paramInfoHeader.iHeight;
    this.iWidth = paramInfoHeader.iWidth;
    this.iImageSize = paramInfoHeader.iImageSize;
    this.iNumColors = paramInfoHeader.iNumColors;
    this.iSize = paramInfoHeader.iSize;
    this.iXpixelsPerM = paramInfoHeader.iXpixelsPerM;
    this.iYpixelsPerM = paramInfoHeader.iYpixelsPerM;
    this.sBitCount = paramInfoHeader.sBitCount;
    this.sPlanes = paramInfoHeader.sPlanes;
  }

  public void write(LittleEndianOutputStream paramLittleEndianOutputStream)
    throws IOException
  {
    paramLittleEndianOutputStream.writeIntLE(this.iSize);
    paramLittleEndianOutputStream.writeIntLE(this.iWidth);
    paramLittleEndianOutputStream.writeIntLE(this.iHeight);
    paramLittleEndianOutputStream.writeShortLE(this.sPlanes);
    paramLittleEndianOutputStream.writeShortLE(this.sBitCount);
    paramLittleEndianOutputStream.writeIntLE(this.iCompression);
    paramLittleEndianOutputStream.writeIntLE(this.iImageSize);
    paramLittleEndianOutputStream.writeIntLE(this.iXpixelsPerM);
    paramLittleEndianOutputStream.writeIntLE(this.iYpixelsPerM);
    paramLittleEndianOutputStream.writeIntLE(this.iColorsUsed);
    paramLittleEndianOutputStream.writeIntLE(this.iColorsImportant);
  }
}